function currying(func){
    const args=[]
    return function result(...rest){
        if(rest.length==0) {
           return func(...args)
        }
        args.push(...rest)
        return result
    }
}
// reducer map filter es6 函数式编程的实现
const add =(...args)=>args.reduce((a,b)=>a+b,0)
const sum = currying(add)
console.log(sum(1)(2)(3)(4)());